<block name='head'><include file='Include/AdminHead' /></block>
<body>
<block name='header'><include file='Include/AdminHeader'/></block>
<block name='slide'><include file='Include/AdminSlide'/></block>

<div class="xr" align="center">
    <div class='xkcontent'>
    
        <div class="xktb_title">
        <i class="fa fa-plus"></i>
        	<button  class="btn btn-danger "><i class="glyphicon glyphicon-trash"></i> 批量删除 </button>
        	<a href="{:U('add')}">
        	<button  class="btn btn-success "><i class="glyphicon glyphicon-plus"></i> 新增记录 </button>
        	</a>
        	<button  class="btn btn-info" id="searchbtn"><i class="glyphicon glyphicon-search"></i> 搜&nbsp;&nbsp;索</button>
        </div>
        <i class="fa fa-plus"></i>
        <form name='search'>
		<table class="xktable xk_setable" border frame=box align='center'>
			<tr>
				<td class="h80 " id='headSearch' style='padding:5px'>
				</td>
			</tr>
		</table>
		</form>
		<table class="xktable table table-striped" border='1' bordercolor="#dedede">
		    <tr class='xktbtitle'></tr>
		    <tbody id='maindata'>
		    
		    </tbody>
		</table>
		<div id='xkpage'></div>
<script type="text/javascript">
	$(document).ready(function(){
		<block name="jsonsearch"></block>
		<block name="jsonHeader"></block>
		var header='';
		url="{:U('ajaxlist')}";
		for(var i=0;i<jsonHeader.length;i++){
            header+='<td>'+jsonHeader[i]['title']+'</td>'  
		}
		var search='';
		for(var i=0;i<jsonsearch.length;i++){
            search+='<div class="fl m5"><span>'+jsonsearch[i]['title']+'</span><br/><input type="text" name="'+jsonsearch[i]['column']+'" /></div>';
		}
		//搜索加载
		$("#headSearch").html(search);
		//table标题加载
		$(".xktbtitle").html(header);
		getData(jsonHeader,url);
		$("body").on('click','#xkpage a',function(){
			var url=$(this).attr('href');
			getData(jsonHeader,url)
			return false;
		});
        //搜索
        var search=new Object();
		$("#searchbtn").click(function(){
			var input=$("form[name='search']").find("input");
            input.each(function(){
            	search[$(this).attr('name')]=$(this).val();
            });
            getData(jsonHeader,url,search)
		});

		//删除操作
		$(document).on("click",".xkdelete",function(){
			var url=$(this).attr('href');
			$.post(url,{},function(data){
                console.log(data);
			});
			return false;
		});

	});
	//table主体加载
    function getData(json,url,where){
        $.post(url,{json:json,where:where},function(data){
        	console.log(data);
        	//debugger
        	data=eval("("+data+")");
            $("#maindata").html(data['data']['tr']);
            $("#xkpage").html(data['data']['page']);
        }); 
    }
</script>
	</div>
</div>  

</body>
</html>